import request from '../utils/request'

// 获取跑腿员列表
export function getRunners(params) {
  return request({
    url: '/errand/runners/',
    method: 'GET',
    params
  })
}

// 获取跑腿员详情
export function getRunnerDetail(id) {
  return request({
    url: `/errand/runners/${id}/`,
    method: 'GET'
  })
}

// 获取订单列表
export function getOrders(params) {
  return request({
    url: '/errand/orders/',
    method: 'GET',
    params
  })
}

// 获取订单详情
export function getOrderDetail(id) {
  return request({
    url: `/errand/orders/${id}/`,
    method: 'GET'
  })
}

// 创建订单
export function createOrder(data) {
  return request({
    url: '/errand/orders/',
    method: 'POST',
    data
  })
}

// 接单
export function acceptOrder(id, data) {
  return request({
    url: `/errand/orders/${id}/accept/`,
    method: 'POST',
    data
  })
}

// 取消订单
export function cancelOrder(id) {
  return request({
    url: `/errand/orders/${id}/cancel/`,
    method: 'PUT'
  })
}

// 完成订单
export function completeOrder(id, data = {}) {
  return request({
    url: `/errand/orders/${id}/complete/`,
    method: 'PUT',
    data
  })
}